import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 求2个整数的最大公约数
 * User: 15085202591
 * Date: 2022-10-31
 * Time: 11:22
 */
public class FindMax {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入2个整数：");
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        if(n1 >= n2){
            int c = n1 % n2;
            while (c != 0){
                n1 = n2;
                n2 = c;
                c = n1 % n2;
            }
            System.out.println("最大公约数为：" + n2);
        }else {
            int k = n2 % n1;
            while (k != 0){
                n2 = n1;
                n1 = k;
                k = n2 % n1;
            }
            System.out.println("最大公约数为：" + n1);
        }
    }
}
